package com.financing.platform.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.financing.platform.dao.IProductRecommendDao;
import com.financing.platform.dto.ProductRecommendDTO;
import com.financing.platform.service.IProductRecommendService;

@Service("productRecommendServiceImpl")
public class ProductRecommendServiceImpl extends BaseServiceImpl implements
		IProductRecommendService {

	@Autowired
	IProductRecommendDao  productRecommendDaoImpl;
	
	public Integer addProductRecommend(ProductRecommendDTO productRecommendDto) {
		try {
			productRecommendDaoImpl.deleteProductRecommend(productRecommendDto);
			if(productRecommendDto.getRecommendWeight() == -1){
				return -1;
			}
			return productRecommendDaoImpl.addProductRecommend(productRecommendDto);
		} catch (SQLException e) {
			log.error("add project recommend error",e);
			return null;
		}
		
	}

	public List<ProductRecommendDTO> queryProductRecommendList(
			ProductRecommendDTO productRecommendDto) {
		return productRecommendDaoImpl.queryProductRecommendList(productRecommendDto);
	}

	public int deleteProductRecommend(ProductRecommendDTO productRecommendDto) throws SQLException {
		return productRecommendDaoImpl.deleteProductRecommend(productRecommendDto);
	}

}
